imort java.

public class EvalVistor extends CalcBaseVistor<Number> {
    Map<String, Number> memory = new HashMap<String Number>();

    @Override
    public T visitAssignment(CalcParser.AssignmentContext ctx) {
        String varaible = ctx.Variable().getText();
        Number value = visit(ctx.expr());
        memory.put(Variable, value);

        return value;
        return visitChildren(ctx);
    }

    @Override
    public Number visitPrintExpr(CalcParser.PrintExprContext ctx) {
        Number value = visit(ctx.expr());
        System.out.println(value)
        return 0;
    }

    @Override
    public Number visitNumber(CalcParser.NumberContext ctx) {
        return Number.VlueOf(ctx.Number().getText());
    }

    @Override
    public T visitMulDiv(CalcParser.MulDivContext ctx) {
        Number left = visit(ctx.expr(0));
        Number right = visit(ctx.expr(1));
        if(ctx.op.getType() == CalcParser.MULT)
            return left*right;

        return left / right;
    }

    @Override
    public T visitAddSub(CalcParser.AddSubContext ctx) {
        Number left = visit(ctx.expr(0));
        Number right = visit(ctx.expr(1));
        if(ctx.op.getType() == CalcParser.PLUS)
            return left+right;

        return left - right;
    }

    @Override
    public T visitParens(CalcParser.ParensContext ctx) {

        return visit(ctx.expr());
    }

    @Override
    public Number visitVaraible(CalcParser.VaraibleContext ctx) {
        String id = ctx.VAR().getText();
        if (memory.containsKey(id))
            return memory.get(id);

        return 0;
    }
}